home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / etc / benchmarks / dhrystone.cc < prev    next >
C/C++ Source or Header  |  1993-11-21  |  22KB  |  702 lines

  1. /****** A Version of the famous dhrystone benchmark ******* */
  2. /* 
  3.  Sun Oct  1 10:40:53 1989  Doug Lea  (dl at g.oswego.edu)
  4.  Changes made to the standard version to run under C++:
  5.  
  6.  * include standard  prototypes for printf and exit
  7.  * include Int.h and Char.h
  8.  * convert all `int' and `char' to `Int' and `Char' 
  9.     (except those needed for timing)
  10.  * predeclare all functions
  11.  * convert all function headers from old-C
  12.  * Change name of struct tms tms to Tms
  13.  * wrote mystrcpy and mystrcmp to handle Chars, not chars
  14.  * added coercion to bad-looking Proc3 call in Proc1
  15.  * initialized String1Loc in Proc0
  16.  * use `new' instead of malloc
  17.  
  18.  
  19. This program is marginally useful in looking at the effects of various
  20. C++ constructs when defining a heavily constructive class like
  21. Int and Char. The Int.h and Char.h files can be compiled several
  22. ways, as listed at the top of each
  23.  
  24. */
  25.  
  26. #include <_G_config.h>
  27. #include "Int.h"
  28. #include "Char.h"
  29.  
  30. /*
  31.  *    "DHRYSTONE" Benchmark Program
  32.  *
  33.  *    Version:    C/1, 12/01/84
  34.  *
  35.  *    Date:        PROGRAM updated 11/02/85, RESULTS updated 12/13/85
  36.  *
  37.  *    Author:        Reinhold P. Weicker,  CACM Vol 27, No 10, 10/84 pg. 1013
  38.  *            Translated from ADA by Rick Richardson
  39.  *            Every method to preserve ADA-likeness has been used,
  40.  *            at the expense of C-ness.
  41.  *
  42.  *    Compile:    cc -O dry.c -o drynr            : No registers
  43.  *            cc -O -DREG=register dry.c -o dryr    : Registers
  44.  *
  45.  *    Defines:    Defines are provided for old C compiler's
  46.  *            which don't have enums, and can't assign structures.
  47.  *            The time(2) function is library dependant; Most
  48.  *            return the time in seconds, but beware of some, like
  49.  *            Aztec C, which return other units.
  50.  *            The LOOPS define is initially set for 50000 loops.
  51.  *            If you have a machine with large integers and is
  52.  *            very fast, please change this number to 500000 to
  53.  *            get better accuracy.  Please select the way to
  54.  *            measure the execution time using the TIME define.
  55.  *            For single user machines, time(2) is adequate. For
  56.  *            multi-user machines where you cannot get single-user
  57.  *            access, use the times(2) function.  If you have
  58.  *            neither, use a stopwatch in the dead of night.
  59.  *            Use a "printf" at the point marked "start timer"
  60.  *            to begin your timings. DO NOT use the UNIX "time(1)"
  61.  *            command, as this will measure the total time to
  62.  *            run this program, which will (erroneously) include
  63.  *            the time to malloc(3) storage and to compute the
  64.  *            time it takes to do nothing.
  65.  *
  66.  *    Run:        drynr; dryr
  67.  *
  68.  *    Results:    If you get any new machine/OS results, please send to:
  69.  *
  70.  *                {ihnp4,vax135,..}!houxm!castor!pcrat!rer
  71.  *
  72.  *            and thanks to all that do.  Space prevents listing
  73.  *            the names of those who have provided some of these
  74.  *            results.
  75.  *
  76.  *    Note:        I order the list in increasing performance of the
  77.  *            "with registers" benchmark.  If the compiler doesn't
  78.  *            provide register variables, then the benchmark
  79.  *            is the same for both REG and NOREG.  I'm not going
  80.  *            to list a compiler in a better place because if it
  81.  *            had register variables it might do better. No
  82.  *            register variables is a big loss in my book.
  83.  *
  84.  *    PLEASE:        Send complete information about the machine type,
  85.  *            clock speed, OS and C manufacturer/version.  If
  86.  *            the machine is modified, tell me what was done.
  87.  *            On UNIX, execute uname -a and cc -V to get this info.
  88.  *
  89.  *    80x8x NOTE:    80x8x benchers: please try to do all memory models
  90.  *            for a particular compiler.
  91.  *
  92.  *--------------------------------RESULTS BEGIN--------------------------------
  93.  *
  94.  * MACHINE    MICROPROCESSOR    OPERATING    COMPILER    DHRYSTONES/SEC.
  95.  * TYPE                SYSTEM                NO REG    REGS
  96.  * --------------------------    ------------    -----------    ---------------
  97.  * Commodore 64    6510-1MHz    C64 ROM        C Power 2.8      36      36
  98.  * HP-110    8086-5.33Mhz    MSDOS 2.11    Lattice 2.14     284     284
  99.  * IBM PC/XT    8088-4.77Mhz    PC/IX        cc         257     287
  100.  * P-E 3205    ?        Xelos(SVR2)     cc         279     296
  101.  * Perq-II    2901 bitslice    Accent S5c     cc (CMU)     301     301
  102.  * IBM PC/XT    8088-4.77Mhz    COHERENT 2.3.43    MarkWilliams cc  296     317
  103.  * Cosmos    68000-8Mhz    UniSoft        cc         305     322
  104.  * IBM PC/XT    8088-4.77Mhz    Venix/86 2.0    cc         297     324
  105.  * DEC PRO 350  11/23           Venix/PRO SVR2  cc               299     325
  106.  * PC/XT        8088-4.77Mhz    Venix/86 SYS V  cc               339     377
  107.  * IBM PC    8088-4.77Mhz    MSDOS 2.0    b16cc 2.0     310     340
  108.  * Commodore Amiga        ?        Lattice 3.02     368     371
  109.  * IBM PC    8088-4.77Mhz    MSDOS 2.0    CI-C86 2.20M     390     390
  110.  * IBM PC/XT    8088-4.77Mhz    PCDOS 2.1    Wizard 2.1     367     403
  111.  * IBM PC/XT    8088-4.77Mhz    PCDOS 3.1    Lattice 2.15     403     403 @
  112.  * IBM PC    8088-4.77Mhz    PCDOS 3.1    Datalight 1.10     416     416
  113.  * IBM PC/XT    8088-4.77Mhz    PCDOS 2.1    Microsoft 3.0     390     427
  114.  * PDP-11/34    -        UNIX V7M    cc         387     438
  115.  * IBM PC    8088, 4.77mhz    PC-DOS 2.1    Aztec C v3.2d     423     454
  116.  * Tandy 1000    V20, 4.77mhz    MS-DOS 2.11    Aztec C v3.2d     423     458
  117.  * PDP-11/34    -        RSTS/E        decus c         438     495
  118.  * Onyx C8002    Z8000-4Mhz    IS/1 1.1 (V7)    cc         476     511
  119.  * Perkin-Elmer 3230        Xelos (SysV.2)    cc         507     565
  120.  * DEC PRO 380  11/73           Venix/PRO SVR2  cc               577     628
  121.  * FHL QT+    68000-10Mhz    Os9/68000    version 1.3     603     649 FH
  122.  * Apollo DN550    68010-?Mhz    AegisSR9/IX    cc 3.12         666     666
  123.  * HP-110    8086-5.33Mhz    MSDOS 2.11    Aztec-C         641     676 
  124.  * ATT PC6300    8086-8Mhz    MSDOS 2.11    b16cc 2.0     632     684
  125.  * IBM PC/AT    80286-6Mhz    PCDOS 3.0    CI-C86 2.1     666     684
  126.  * Tandy 6000    68000-8Mhz    Xenix 3.0    cc         694     694
  127.  * IBM PC/AT    80286-6Mhz    Xenix 3.0    cc         684     704 MM
  128.  * Macintosh    68000-7.8Mhz 2M    Mac Rom        Mac C 32 bit int 694     704
  129.  * Macintosh    68000-7.7Mhz    -        MegaMax C 2.0     661     709
  130.  * IBM PC/AT    80286-6Mhz    Xenix 3.0    cc         704     714 LM
  131.  * Codata 3300    68000-8Mhz    UniPlus+ (v7)    cc         678     725
  132.  * Cadmus 9000    68010-10Mhz    UNIX        cc         714     735
  133.  * AT&T 6300    8086-8Mhz       Venix/86 SVR2   cc               668     743
  134.  * Cadmus 9790    68010-10Mhz 1MB    SVR0,Cadmus3.7    cc         720     747
  135.  * NEC PC9801F    8086-8Mhz    PCDOS 2.11    Lattice 2.15     768      -  @
  136.  * ATT PC6300    8086-8Mhz    MSDOS 2.11    CI-C86 2.20M     769     769
  137.  * Burroughs XE550 68010-10Mhz    Centix 2.10    cc         769     769 CT1
  138.  * EAGLE/TURBO  8086-8Mhz       Venix/86 SVR2   cc               696     779
  139.  * ALTOS 586    8086-10Mhz    Xenix 3.0b    cc          724     793
  140.  * DEC 11/73    J-11 micro    Ultrix-11 V3.0    System V     735     793
  141.  * ATT 3B2/300    WE32000-?Mhz    UNIX 5.0.2    cc         735     806
  142.  * Apollo DN320    68010-?Mhz    AegisSR9/IX    cc 3.12         806     806
  143.  * IRIS-2400    68010-10Mhz    UNIX System V    cc         772     829
  144.  * Atari 520ST  68000-8Mhz      TOS             DigResearch      839     846
  145.  * IBM PC/AT    80286-6Mhz    PCDOS 3.0    MS 3.0(large)     833     847 LM
  146.  * VAX 11/750    -        Ultrix 1.1    4.2BSD cc     781     862
  147.  * P-E  7350A    68000-8MHz    UniSoft V.2    cc         821     875
  148.  * VAX 11/750    -        UNIX 4.2bsd    cc         862     877
  149.  * Fast Mac    68000-7.7Mhz    -        MegaMax C 2.0     839     904 +
  150.  * IBM PC/XT    8086-9.54Mhz    PCDOS 3.1    Microsoft 3.0     833     909 C1
  151.  * DEC 11/44            Ultrix-11 V3.0    System V     862     909
  152.  * Macintosh    68000-7.8Mhz 2M    Mac Rom        Mac C 16 bit int 877     909 S
  153.  * P-E 3210    ?        Xelos R01(SVR2)    cc         849     924
  154.  * P-E 3220    ?               Ed. 7 v2.3      cc         892     925
  155.  * IBM PC/AT    80286-6Mhz    Xenix 3.0    cc -i         909     925
  156.  * AT&T 6300    8086, 8mhz    MS-DOS 2.11    Aztec C v3.2d     862     943
  157.  * IBM PC/AT    80286-6Mhz    Xenix 3.0    cc         892     961
  158.  * VAX 11/750    w/FPA        Eunice 3.2    cc         914     976
  159.  * IBM PC/XT    8086-9.54Mhz    PCDOS 3.1    Wizard 2.1     892     980 C1
  160.  * IBM PC/XT    8086-9.54Mhz    PCDOS 3.1    Lattice 2.15     980     980 C1
  161.  * Plexus P35    68000-10Mhz    UNIX System III cc         984     980
  162.  * PDP-11/73    KDJ11-AA 15Mhz    UNIX V7M 2.1    cc         862     981
  163.  * VAX 11/750    w/FPA        UNIX 4.3bsd    cc         994     997
  164.  * IRIS-1400    68010-10Mhz    UNIX System V    cc         909    1000
  165.  * IBM PC/AT    80286-6Mhz    Venix/86 2.1    cc         961    1000
  166.  * IBM PC/AT    80286-6Mhz    PCDOS 3.0    b16cc 2.0     943    1063
  167.  * Zilog S8000/11 Z8001-5.5Mhz    Zeus 3.2    cc        1011    1084
  168.  * NSC ICM-3216 NSC 32016-10Mhz    UNIX SVR2    cc        1041    1084
  169.  * IBM PC/AT    80286-6Mhz    PCDOS 3.0    MS 3.0(small)    1063    1086
  170.  * VAX 11/750    w/FPA        VMS        VAX-11 C 2.0     958    1091
  171.  * Stride    68000-10Mhz    System-V/68    cc        1041    1111
  172.  * ATT PC7300    68010-10Mhz    UNIX 5.2    cc        1041    1111
  173.  * P-E 3230    ?        Xelos R01(SVR2)    cc        1040    1126
  174.  * Stride    68000-12Mhz    System-V/68    cc        1063    1136
  175.  * IBM PC/AT    80286-6Mhz      Venix/286 SVR2  cc              1056    1149
  176.  * IBM PC/AT    80286-6Mhz    PCDOS 3.0    Datalight 1.10    1190    1190
  177.  * ATT PC6300+    80286-6Mhz    MSDOS 3.1    b16cc 2.0    1111    1219
  178.  * IBM PC/AT    80286-6Mhz    PCDOS 3.1    Wizard 2.1    1136    1219
  179.  * Sun2/120    68010-10Mhz    Sun 4.2BSD    cc        1136    1219
  180.  * IBM PC/AT    80286-6Mhz    PCDOS 3.0    CI-C86 2.20M    1219    1219
  181.  * MASSCOMP 500    68010-10MHz    RTU V3.0    cc (V3.2)    1156    1238
  182.  * Cyb DataMate    68010-12.5Mhz    Uniplus 5.0    Unisoft cc    1162    1250
  183.  * PDP 11/70    -        UNIX 5.2    cc        1162    1250
  184.  * IBM PC/AT    80286-6Mhz    PCDOS 3.1    Lattice 2.15    1250    1250
  185.  * IBM PC/AT    80286-7.5Mhz    Venix/86 2.1    cc        1190    1315 *15
  186.  * Sun2/120    68010-10Mhz    Standalone    cc        1219    1315
  187.  * Intel 380    80286-8Mhz    Xenix R3.0up1    cc        1250    1315 *16
  188.  * ATT 3B2/400    WE32100-?Mhz    UNIX 5.2    cc        1315    1315
  189.  * P-E 3250XP    -        Xelos R01(SVR2)    cc        1215    1318
  190.  * DG MV4000    -        AOS/VS 5.00    cc        1333    1333
  191.  * IBM PC/AT    80286-8Mhz    Venix/86 2.1    cc        1275    1380 *16
  192.  * IBM PC/AT    80286-6Mhz    MSDOS 3.0    Microsoft 3.0    1250    1388
  193.  * ATT PC6300+    80286-6Mhz    MSDOS 3.1    CI-C86 2.20M    1428    1428
  194.  * COMPAQ/286   80286-8Mhz      Venix/286 SVR2  cc              1326    1443
  195.  * IBM PC/AT    80286-7.5Mhz    Venix/286 SVR2  cc              1333    1449 *15
  196.  * Cyb DataMate    68010-12.5Mhz    Uniplus 5.0    Unisoft cc    1470    1562 S
  197.  * VAX 11/780    -        UNIX 5.2    cc        1515    1562
  198.  * MicroVAX-II    -        -        -        1562    1612
  199.  * VAX 11/780    -        UNIX 4.3bsd    cc        1646    1662
  200.  * Apollo DN660    -        AegisSR9/IX    cc 3.12        1666    1666
  201.  * ATT 3B20    -        UNIX 5.2    cc        1515    1724
  202.  * NEC PC-98XA    80286-8Mhz    PCDOS 3.1    Lattice 2.15    1724    1724 @
  203.  * HP9000-500    B series CPU    HP-UX 4.02    cc        1724    -
  204.  * IBM PC/STD    80286-8Mhz    MSDOS 3.0     Microsoft 3.0    1724    1785 C2
  205.  * DEC-2065    KL10-Model B    TOPS-20 6.1FT5    Port. C Comp.    1937    1946
  206.  * Gould PN6005    -        UTX 1.1(4.2BSD)    cc        1675    1964
  207.  * DEC2060    KL-10        TOPS-20        cc        2000    2000 &
  208.  * VAX 11/785    -        UNIX 5.2    cc        2083    2083
  209.  * VAX 11/785    -        VMS        VAX-11 C 2.0    2083    2083
  210.  * VAX 11/785    -        UNIX SVR2    cc        2123    2083
  211.  * VAX 11/785    -        UNIX 4.3bsd    cc        2135    2136
  212.  * Pyramid 90x    -        OSx 2.3        cc        2272    2272
  213.  * Pyramid 90x    FPA,cache,4Mb    OSx 2.5        cc no -O    2777    2777
  214.  * Alliant FX-8 CE        ?        ?        2622    2901 FX
  215.  * Pyramid 90x    w/cache        OSx 2.5        cc w/-O        3333    3333
  216.  * IBM-4341-II    -        VM/SP3        Waterloo C 1.2  3333    3333
  217.  * IRIS-2400T    68020-16.67Mhz    UNIX System V    cc        3105    3401
  218.  * SUN 3/75    68020-16.67Mhz    SUN 4.2 V3    cc        3333    3571
  219.  * IBM-4341    Model 12    UTS 5.0        ?        3685    3685
  220.  * SUN-3/160    68020-16.67Mhz  Sun 4.2 V3.0A   cc        3381    3764
  221.  * Sun 3/180    68020-16.67Mhz    Sun 4.2        cc        3333    3846
  222.  * IBM-4341    Model 12    UTS 5.0        ?        3910    3910 MN
  223.  * MC 5400    68020-16.67MHz    RTU V3.0    cc (V4.0)    3952    4054
  224.  * NCR Tower32  68020-16.67Mhz  SYS 5.0 Rel 2.0 cc              3846    4545
  225.  * Gould PN9080    -        UTX-32 1.1c    cc        -    4629
  226.  * MC 5600/5700    68020-16.67MHz    RTU V3.0    cc (V4.0)    4504    4746 %
  227.  * Gould 1460-342 ECL proc      UTX/32 1.1/c    cc              5342    5677 G1
  228.  * VAX 8600    -        UNIX 4.3bsd    cc        7024    7088
  229.  * VAX 8600    -        VMS        VAX-11 C 2.0    7142    7142
  230.  * CCI POWER 6/32        COS(SV+4.2)    cc        7500    7800
  231.  * CCI POWER 6/32        POWER 6 UNIX/V    cc        8236    8498
  232.  * CCI POWER 6/32        4.2 Rel. 1.2b    cc        8963    9544
  233.  * Sperry (CCI Power 6)        4.2BSD        cc        9345   10000
  234.  * CRAY-X-MP/12       105Mhz    COS 1.14    Cray C         10204   10204
  235.  * IBM-3083    -        UTS 5.0 Rel 1    cc           16666   12500
  236.  * CRAY-1A        80Mhz    CTSS        Cray C 2.0     12100   13888
  237.  * IBM-3083    -        VM/CMS HPO 3.4    Waterloo C 1.2 13889   13889
  238.  * Amdahl 470 V/8         UTS/V 5.2       cc v1.23       15560   15560
  239.  * CRAY-X-MP/48       105Mhz    CTSS        Cray C 2.0     15625   17857
  240.  * Amdahl 580    -        UTS 5.0 Rel 1.2    cc v1.5        23076   23076
  241.  * Amdahl 5860             UTS/V 5.2       cc v1.23       28970   28970
  242.  *
  243.  *   *   Crystal changed from 'stock' to listed value.
  244.  *   +   This Macintosh was upgraded from 128K to 512K in such a way that
  245.  *       the new 384K of memory is not slowed down by video generator accesses.
  246.  *   %   Single processor; MC == MASSCOMP
  247.  *   &   A version 7 C compiler written at New Mexico Tech.
  248.  *   @   vanilla Lattice compiler used with MicroPro standard library
  249.  *   S   Shorts used instead of ints
  250.  *   LM  Large Memory Model. (Otherwise, all 80x8x results are small model)
  251.  *   MM  Medium Memory Model. (Otherwise, all 80x8x results are small model)
  252.  *   C1  Univation PC TURBO Co-processor; 9.54Mhz 8086, 640K RAM
  253.  *   C2  Seattle Telecom STD-286 board
  254.  *   C?  Unknown co-processor board?
  255.  *   CT1 Convergent Technologies MegaFrame, 1 processor.
  256.  *   MN  Using Mike Newtons 'optimizer' (see net.sources).
  257.  *   G1  This Gould machine has 2 processors and was able to run 2 dhrystone
  258.  *       Benchmarks in parallel with no slowdown.
  259.  *   FH  FHC == Frank Hogg Labs (Hazelwood Uniquad 2 in an FHL box).
  260.  *   FX  The FX-8 has two kinds of processors.  This figure is for CE's
  261.  *     (computation engines).  The other processor type is an IP (interactive
  262.  *     processor) which is a 68010-12Mhz. Figures were not precisely
  263.  *     determined for the IP.
  264.  *   ?   I don't trust results marked with '?'.  These were sent to me with
  265.  *       either incomplete info, or with times that just don't make sense.
  266.  *     ?? means I think the performance is too poor, ?! means too good.
  267.  *       If anybody can confirm these figures, please respond.
  268.  *
  269.  *--------------------------------RESULTS END----------------------------------
  270.  *
  271.  *    The following program contains statements of a high-level programming
  272.  *    language (C) in a distribution considered representative:
  273.  *
  274.  *    assignments            53%
  275.  *    control statements        32%
  276.  *    procedure, function calls    15%
  277.  *
  278.  *    100 statements are dynamically executed.  The program is balanced with
  279.  *    respect to the three aspects:
  280.  *        - statement type
  281.  *        - operand type (for simple data types)
  282.  *        - operand access
  283.  *            operand global, local, parameter, or constant.
  284.  *
  285.  *    The combination of these three aspects is balanced only approximately.
  286.  *
  287.  *    The program does not compute anything meaningfull, but it is
  288.  *    syntactically and semantically correct.
  289.  *
  290.  */
  291.  
  292. /* Accuracy of timings and human fatigue controlled by next two lines */
  293. #ifdef QUICK
  294. #define LOOPS    50000        /* Use this for slow or 16 bit machines */
  295. #else
  296. #define LOOPS    500000        /* Use this for faster machines */
  297. #endif
  298.  
  299. /* Compiler dependent options */
  300. #undef    NOENUM            /* Define if compiler has no enum's */
  301. #undef    NOSTRUCTASSIGN        /* Define if compiler can't assign structures */
  302. /* cfront 3.0 can't handle the assignments */
  303. #ifndef __GNUG__
  304. #define    NOSTRUCTASSIGN
  305. #endif
  306.  
  307.  
  308. /* define only one of the next two defines */
  309. #ifndef _G_SYSV
  310. #define TIMES            /* Use times(2) time function */
  311. #else
  312. #define TIME            /* Use time(2) time function */
  313. #endif
  314.  
  315. #ifdef TIMES
  316. #include <sys/types.h>
  317. #include <sys/times.h>
  318. #endif
  319. #ifdef TIME
  320. #include <time.h>
  321. #endif
  322.  
  323. /* define the granularity of your times(2) function (when used) */
  324. #ifndef HZ
  325. #if 1
  326. #define HZ    60        /* times(2) returns 1/60 second (most) */
  327. #else
  328. #define HZ    100        /* times(2) returns 1/100 second (WECo) */
  329. #endif
  330. #endif
  331.  
  332.  
  333. #ifdef    NOSTRUCTASSIGN
  334. #include <string.h>
  335. #define    structassign(d, s)    memcpy(&(d), &(s), sizeof(d))
  336. #else
  337. #define    structassign(d, s)    d = s
  338. #endif
  339.  
  340. #ifdef    NOENUM
  341. #define    Ident1    1
  342. #define    Ident2    2
  343. #define    Ident3    3
  344. #define    Ident4    4
  345. #define    Ident5    5
  346. typedef int    Enumeration;
  347. #else
  348. typedef enum    {Ident1, Ident2, Ident3, Ident4, Ident5} Enumeration;
  349. #endif
  350.  
  351.  
  352.  
  353. typedef Int    OneToThirty;
  354. typedef Int    OneToFifty;
  355. typedef Char    CapitalLetter;
  356. typedef Char    String30[31];
  357. typedef Int    Array1Dim[51];
  358. typedef Int    Array2Dim[51][51];
  359.  
  360. struct    Record
  361. {
  362.     struct Record        *PtrComp;
  363.     Enumeration        Discr;
  364.     Enumeration        EnumComp;
  365.     OneToFifty        IntComp;
  366.     String30        StringComp;
  367. };
  368.  
  369. typedef struct Record     RecordType;
  370. typedef RecordType *    RecordPtr;
  371. typedef int        dhry_boolean;
  372.  
  373. #define    TRUE        1
  374. #define    FALSE        0
  375.  
  376. #ifndef REG
  377. #define    REG
  378. #endif
  379.  
  380.  
  381. /* added: - dl */
  382.  
  383. extern "C" {
  384. extern int printf(const char* ...);
  385. extern void exit(int);
  386. }
  387.  
  388. void Proc0();
  389. void Proc1(RecordPtr PtrParIn);
  390. void Proc2(OneToFifty    *IntParIO);
  391. void Proc3(RecordPtr    *PtrParOut);
  392. void Proc4();
  393. void Proc5();
  394. dhry_boolean Func3(Enumeration    EnumParIn);
  395. void Proc6(REG Enumeration    EnumParIn, REG Enumeration    *EnumParOut);
  396. void Proc7(OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty *IntParOut);
  397. void Proc8(Array1Dim    Array1Par, 
  398.       Array2Dim    Array2Par, 
  399.       OneToFifty IntParI1, 
  400.       OneToFifty IntParI2);
  401. Enumeration Func1(CapitalLetter    CharPar1, CapitalLetter    CharPar2);
  402. dhry_boolean Func2(String30    StrParI1, String30    StrParI2);
  403. dhry_boolean Func3(Enumeration    EnumParIn);
  404.  
  405. void mystrcpy(String30 s, char* t)
  406. {
  407.   for (; *t != '\0'; ++s, ++t) *s = *t;
  408.   *s = '\0';
  409. }
  410.  
  411. char mystrcmp(String30 s, String30 t)
  412. {
  413.   for (; *s == *t; ++s, ++t) if (*s == '\0') return 0;
  414.   return char(*s - *t);
  415. }
  416.  
  417. /*end - dl */
  418.  
  419. main()
  420. {
  421.     Proc0();
  422.     exit(0);
  423. }
  424.  
  425. /*
  426.  * Package 1
  427.  */
  428. Int        IntGlob;
  429. dhry_boolean        BoolGlob;
  430. char        Char1Glob;
  431. char        Char2Glob;
  432. Array1Dim    Array1Glob;
  433. Array2Dim    Array2Glob;
  434. RecordPtr    PtrGlb;
  435. RecordPtr    PtrGlbNext;
  436.  
  437. void Proc0()
  438. {
  439.     OneToFifty        IntLoc1;
  440.     REG OneToFifty        IntLoc2;
  441.     OneToFifty        IntLoc3;
  442.     REG char        CharLoc;
  443.     REG char        CharIndex;
  444.     Enumeration         EnumLoc;
  445.     String30        String1Loc;
  446.     String30        String2Loc;
  447.  
  448. #ifdef TIME
  449.     long            starttime;
  450.     long            benchtime;
  451.     long            nulltime;
  452.     register unsigned int    i;
  453.  
  454.     starttime = time( (_G_time_t *) 0);
  455.     for (i = 0; i < LOOPS; ++i);
  456.     nulltime = time( (_G_time_t*) 0) - starttime; /* Computes o'head of loop */
  457. #endif
  458. #ifdef TIMES
  459.     time_t            starttime;
  460.     time_t            benchtime;
  461.     time_t            nulltime;
  462.     struct tms        Tms;
  463.     register unsigned int    i;
  464.  
  465.     times(&Tms); starttime = Tms.tms_utime;
  466.     for (i = 0; i < LOOPS; ++i);
  467.     times(&Tms);
  468.     nulltime = Tms.tms_utime - starttime; /* Computes overhead of looping */
  469. #endif
  470.  
  471.     PtrGlbNext = new Record;
  472.     PtrGlb = new Record;
  473.     PtrGlb->PtrComp = PtrGlbNext;
  474.     PtrGlb->Discr = Ident1;
  475.     PtrGlb->EnumComp = Ident3;
  476.     PtrGlb->IntComp = 40;
  477.     mystrcpy(PtrGlb->StringComp, "DHRYSTONE PROGRAM, SOME STRING");
  478.     mystrcpy(String1Loc, "JUST INITIALIZED TO SOME JUNK.");
  479.  
  480. /*****************
  481. -- Start Timer --
  482. *****************/
  483. #ifdef TIME
  484.     starttime = time( (_G_time_t*) 0);
  485. #endif
  486. #ifdef TIMES
  487.     times(&Tms); starttime = Tms.tms_utime;
  488. #endif
  489.     for (i = 0; i < LOOPS; ++i)
  490.     {
  491.  
  492.         Proc5();
  493.         Proc4();
  494.         IntLoc1 = 2;
  495.         IntLoc2 = 3;
  496.         mystrcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
  497.         EnumLoc = Ident2;
  498.         BoolGlob = ! Func2(String1Loc, String2Loc);
  499.         while (IntLoc1 < IntLoc2)
  500.         {
  501.             IntLoc3 = 5 * IntLoc1 - IntLoc2;
  502.             Proc7(IntLoc1, IntLoc2, &IntLoc3);
  503.             ++IntLoc1;
  504.         }
  505.         Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3);
  506.         Proc1(PtrGlb);
  507.         for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex)
  508.             if (EnumLoc == Func1(CharIndex, 'C'))
  509.                 Proc6(Ident1, &EnumLoc);
  510.         IntLoc3 = IntLoc2 * IntLoc1;
  511.         IntLoc2 = IntLoc3 / IntLoc1;
  512.         IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1;
  513.         Proc2(&IntLoc1);
  514.     }
  515.  
  516. /*****************
  517. -- Stop Timer --
  518. *****************/
  519.  
  520. #ifdef TIME
  521.     benchtime = time( (_G_time_t *) 0) - starttime - nulltime;
  522.     printf("Dhrystone time for %ld passes = %ld\n",
  523.         (long) LOOPS, benchtime);
  524.     if (benchtime)
  525.       printf("This machine benchmarks at %ld dhrystones/second\n",
  526.          ((long) LOOPS) / benchtime);
  527. #endif
  528. #ifdef TIMES
  529.     times(&Tms);
  530.     benchtime = Tms.tms_utime - starttime - nulltime;
  531.     printf("Dhrystone time for %ld passes = %ld\n",
  532.         (long) LOOPS, benchtime/HZ);
  533.     if (benchtime)
  534.       printf("This machine benchmarks at %ld dhrystones/second\n",
  535.          ((long) LOOPS) * HZ / benchtime);
  536. #endif
  537.  
  538. }
  539.  
  540. void Proc1(RecordPtr PtrParIn)
  541. {
  542. #define    NextRecord    (*(PtrParIn->PtrComp))
  543.  
  544.     structassign(NextRecord, *PtrGlb);
  545.     PtrParIn->IntComp = 5;
  546.     NextRecord.IntComp = PtrParIn->IntComp;
  547.     NextRecord.PtrComp = PtrParIn->PtrComp;
  548. /* - added coercion (glossing over error in original code) - dl */
  549.     Proc3(&(NextRecord.PtrComp));
  550.     if (NextRecord.Discr == Ident1)
  551.     {
  552.         NextRecord.IntComp = 6;
  553.         Proc6(PtrParIn->EnumComp, &NextRecord.EnumComp);
  554.         NextRecord.PtrComp = PtrGlb->PtrComp;
  555.         Proc7(NextRecord.IntComp, 10, &NextRecord.IntComp);
  556.     }
  557.     else
  558.         structassign(*PtrParIn, NextRecord);
  559.  
  560. #undef    NextRecord
  561. }
  562.  
  563. void Proc2(OneToFifty    *IntParIO)
  564. {
  565.     REG OneToFifty        IntLoc;
  566.     REG Enumeration        EnumLoc;
  567.  
  568.     IntLoc = *IntParIO + 10;
  569.     for(;;)
  570.     {
  571.         if (Char1Glob == 'A')
  572.         {
  573.             --IntLoc;
  574.             *IntParIO = IntLoc - IntGlob;
  575.             EnumLoc = Ident1;
  576.         }
  577.         if (EnumLoc == Ident1)
  578.             break;
  579.     }
  580. }
  581.  
  582. void Proc3(RecordPtr    *PtrParOut)
  583. {
  584.     if (PtrGlb)
  585.         *PtrParOut = PtrGlb->PtrComp;
  586.     else
  587.         IntGlob = 100;
  588.     Proc7(10, IntGlob, &PtrGlb->IntComp);
  589. }
  590.  
  591. void Proc4()
  592. {
  593.     REG dhry_boolean    BoolLoc;
  594.  
  595.     BoolLoc = Char1Glob == 'A';
  596.     BoolLoc |= BoolGlob;
  597.     Char2Glob = 'B';
  598. }
  599.  
  600. void Proc5()
  601. {
  602.     Char1Glob = 'A';
  603.     BoolGlob = FALSE;
  604. }
  605.  
  606.  
  607.  
  608.  
  609. void Proc6(REG Enumeration    EnumParIn, REG Enumeration    *EnumParOut)
  610. {
  611.     *EnumParOut = EnumParIn;
  612.     if (! Func3(EnumParIn) )
  613.         *EnumParOut = Ident4;
  614.     switch (EnumParIn)
  615.     {
  616.     case Ident1:    *EnumParOut = Ident1; break;
  617.     case Ident2:    if (IntGlob > 100) *EnumParOut = Ident1;
  618.             else *EnumParOut = Ident4;
  619.             break;
  620.     case Ident3:    *EnumParOut = Ident2; break;
  621.     case Ident4:    break;
  622.     case Ident5:    *EnumParOut = Ident3;
  623.     }
  624. }
  625.  
  626. void Proc7(OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty *IntParOut)
  627. {
  628.     REG OneToFifty    IntLoc;
  629.  
  630.     IntLoc = IntParI1 + 2;
  631.     *IntParOut = IntParI2 + IntLoc;
  632. }
  633.  
  634. void Proc8(Array1Dim    Array1Par, 
  635.       Array2Dim    Array2Par, 
  636.       OneToFifty IntParI1, 
  637.       OneToFifty IntParI2)
  638. {
  639.     REG OneToFifty    IntLoc;
  640.     REG OneToFifty    IntIndex;
  641.  
  642.     IntLoc = IntParI1 + 5;
  643.     Array1Par[IntLoc] = IntParI2;
  644.     Array1Par[IntLoc+1] = Array1Par[IntLoc];
  645.     Array1Par[IntLoc+30] = IntLoc;
  646.     for (IntIndex = IntLoc; IntIndex <= (IntLoc+1); ++IntIndex)
  647.         Array2Par[IntLoc][IntIndex] = IntLoc;
  648.     ++Array2Par[IntLoc][IntLoc-1];
  649.     Array2Par[IntLoc+20][IntLoc] = Array1Par[IntLoc];
  650.     IntGlob = 5;
  651. }
  652.  
  653. Enumeration Func1(CapitalLetter    CharPar1, CapitalLetter    CharPar2)
  654. {
  655.     REG CapitalLetter    CharLoc1;
  656.     REG CapitalLetter    CharLoc2;
  657.  
  658.     CharLoc1 = CharPar1;
  659.     CharLoc2 = CharLoc1;
  660.     if (CharLoc2 != CharPar2)
  661.         return (Ident1);
  662.     else
  663.         return (Ident2);
  664. }
  665.  
  666. dhry_boolean Func2(String30    StrParI1, String30    StrParI2)
  667. {
  668.     REG OneToThirty        IntLoc;
  669.     REG CapitalLetter    CharLoc;
  670.  
  671.     IntLoc = 1;
  672.     while (IntLoc <= 1)
  673.         if (Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) == Ident1)
  674.         {
  675.             CharLoc = 'A';
  676.             ++IntLoc;
  677.         }
  678.     if (CharLoc >= 'W' && CharLoc <= 'Z')
  679.         IntLoc = 7;
  680.     if (CharLoc == 'X')
  681.         return(TRUE);
  682.     else
  683.     {
  684.         if (mystrcmp(StrParI1, StrParI2) > 0)
  685.         {
  686.             IntLoc += 7;
  687.             return (TRUE);
  688.         }
  689.         else
  690.             return (FALSE);
  691.     }
  692. }
  693.  
  694. dhry_boolean Func3(Enumeration    EnumParIn)
  695. {
  696.     REG Enumeration    EnumLoc;
  697.  
  698.     EnumLoc = EnumParIn;
  699.     if (EnumLoc == Ident3) return (TRUE);
  700.     return (FALSE);
  701. }
  702.